$(function () {
    //点击全选
    $('#checkAll').click(function(){
        var elems = $("input[type='checkbox']").not($(this));
        for (var i=0; i < elems.length; i++)
        {
            elems[i].checked = $(this).is(':checked');
        }
    });
});

/*ajax批量删除*/
function delAll (url) {
    var data = tableCheck.getData();
    layer.confirm('确认要删除吗？',function(index){
        // 捉到所有被选中的，发异步进行删除
        $ids = new Array();
        $obj = $("input[name='id']:checked");
        for (var i = 0; i < $obj.length; i++) {
            $ids.push($obj[i].value);
        }
        $.post(url, {ids:$ids}, function(data){
            if(data.code == 0){
                layer.msg('删除成功', {icon: 1});
                location.replace(location.href);
            }else{
                layer.msg('系统错误', {icon: 2});
            }
        });
    });
} 

/*ajax删除一个*/
function delOne(url,id){
    layer.confirm('确认要删除吗？',function(index){
        //发异步删除数据
        $.post(url, {ids:id}, function(data){
            if(data.code == 0){
                layer.msg('删除成功', {icon: 1});
                location.replace(location.href);
            }else{
                layer.msg('系统错误', {icon: 2});
            }
        });
    });
}